﻿using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using NPOI.POIFS.FileSystem;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Autodesk.Revit.UI.Selection;
using ZhuXingFamilys.AuditIndicators.Entity;
using ZhuXingFamilys.AuditIndicators.utils;
using Visibility = System.Windows.Visibility;
using Autodesk.Revit.DB.Plumbing;
using ZhuXingFamilys.ModelInformation.Entity.Engineering;
using ZhuXingFamilys.ModelInformation.Entity;
using System.Xml.Linq;
using System.IO.Pipelines;
using Floor = Autodesk.Revit.DB.Floor;
using Pipe = Autodesk.Revit.DB.Plumbing.Pipe;
using System.Threading.Tasks;

namespace ZhuXingFamilys.AuditIndicators
{
    /// <summary>
    /// RealAndModel.xaml 的交互逻辑
    /// </summary>
    public partial class RealAndModel : Window
    {
        private static RealAndModel instance = null;
        private UIApplication UIApp;
        private Document doc;
        // 链接模型是否检查完成
        public static bool LinkInstanceChecked = false;
        private CheckLinkInstance checkLinkInstance;
        private ExternalEvent checkLinkInstanceEvent;

        // 后台任务
        private BackgroundWorker backWork = new BackgroundWorker();

        // 审查结论表
        private List<conclusion> conclusions;

        // 自动审核指标
        private List<indicatorDetails> automaticReviewMetricsList;
        // 自动备案指标
        private List<indicatorDetails> automaticFilingMetricsList;

        public RealAndModel(UIApplication uiapp)
        {
            UIApp = uiapp;
            doc = uiapp.ActiveUIDocument.Document;
            //ui库使用
            ColorZoneAssist.SetMode(new GroupBox(), ColorZoneMode.Light);
            Hue hue = new Hue("name", System.Windows.Media.Color.FromArgb(1, 2, 3, 4),
                System.Windows.Media.Color.FromArgb(1, 5, 6, 7));
            InitializeComponent();
            // 创建检查链接模型的外部事件
            checkLinkInstance = new CheckLinkInstance();
            checkLinkInstanceEvent = ExternalEvent.Create(checkLinkInstance);
            // 创建空闲事件监听链接模型是否检查完成
            uiapp.Idling += CheckLinkInsetanceResult;

            // 注册后台任务
            backWork.WorkerReportsProgress = true;
            backWork.WorkerSupportsCancellation = false;
            backWork.DoWork += backWork_DoWork;
            backWork.RunWorkerCompleted += backWork_RunWorkerCompleted;
            backWork.ProgressChanged += BackWorkOnProgressChanged;
            // 解决嵌套Data
            // 鼠标滚动不响应
            ConclusionListViewdDataGrid.PreviewMouseWheel += DataGrid_PreviewMouseWheel;
            AutomaticReviewMetrics.PreviewMouseWheel += DataGrid_PreviewMouseWheel;
            AutomaticFilingMetrics.PreviewMouseWheel += DataGrid_PreviewMouseWheel;
        }

        // 创建空闲事件监听链接模型是否检查完成 
        private void CheckLinkInsetanceResult(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
          {
            // 链接模型检查完成
            if (LinkInstanceChecked)
            {
                // 注销空闲事件
                UIApp.Idling -= CheckLinkInsetanceResult;
                // 开始执行后台任务
                backWork.RunWorkerAsync();
            }

            LinkInstanceChecked = true;
        }
        // 窗口加载完成
        private async void RealAndModel_OnLoaded(object sender, RoutedEventArgs e)
        {
            // 检查处理链接模型
            Label1.Content = "正在检查链接模型数据格式，请稍等...";
            await Task.Run(() =>
            {
                // 执行检查链接模型的操作
                checkLinkInstanceEvent.Raise();
            });

            // checkLinkInstanceEvent.Raise();

            // backWork.RunWorkerAsync();
        }

        // 正在执行
        void backWork_DoWork(object sender, DoWorkEventArgs e)
        {
            // 指标明细表数据
            // 自动审核指标
            automaticReviewMetricsList = new List<indicatorDetails>
            {
                // 用地红线
                analysisRedLine(),
                // 地上建筑退界
                analysisBuildingRetreat(),
                //地块主功能建筑面积占比
                analysisUnderground(),
                // 主功能建筑面积
                analysisBuildingRoomArea(),
                // 容积率
                analysisPlotRatio(),
                // 绿地率
                analysisGreenspaceRate(),
                // 建筑密度
                analysisBuildingDensity(),
                // 总建筑面积
                analysisOverallFloorage(),
                // 地上总建筑面积
                analysisUpOverallFloorage(),
                // 地下总建筑面积
                analysisBelowOverallFloorage(),
                // 计容建筑面积
                analysisCapacityArea(),
                // 场地标高
                analysisSiteLevels(),
                // 建筑(构筑物)高度
                analysisBuildingHeight(),
                // 地下建筑范围
                analysisBelowBuildingZone(),
                // 地下建筑标高
                analysisBelowBuildingElevation(),
                // 配建公共服务设施类型
                analysisTypesOfPublicServiceFacilities(),
                // 配建公共服务设施规模
                analysisAreaOfPublicServiceFacilities(),
                // 配建公共服务设施位置
                analysisPositionOfPublicServiceFacilities(),
                // 地块机动车出入口
                analysisSubwayEntrance(),
                // 公共通道
                analysisCommonAisle(),
                // 机动车停车位数量
                analysisParkingSpotCount(),
                // 非机动车停车面积
                analysisNonMotorParking(),
                // 战时功能
                analysisWartimeFunction(),
                // 抗力等级
                analysisResistanceLevel(),
                // 防化级别
                analysisChemicalPreventionLevel(),
                // 人防总建筑面积
                analysisCivilAirDefenseBuildingArea(),
                // 植物配置
                analysisBotany(),
                // 贴线率
                analysisAttachmentRate(),
                // 坡屋顶比例
                analysisSlopeRoofRatio(),
                // 建筑(整体)窗墙比
                analysisWindowWallRatio(),
                // 建筑室外设备
                analysisOutdoorEquipment(),
                // 独立站、机房
                analysisIndependentStation(),
                // 建筑布局
                analysisArchitecturalComposition(),
                // 夜景照明
                analysisNightscapeLighting(),
                // 建筑标识
                analysisBuildingSign(),
                // 立面形式
                analysisElevationForm(),
                // 出入口构筑物
                analysisPassageway(),
                // 日照
                analysisSunlight(),
                // 市政接驳点位置
                analysisMunicipalConnectionPoint(),
            };
            // 自动备案指标
            automaticFilingMetricsList = new List<indicatorDetails>
            {
                // 项目编号
                analysisProjectCode(),
                // 项目名称
                analysisProjectName(),
                // 地块编号
                analysisPlotCode(),
                // 用地性质
                analysisLandUsage(),
                // 用地面积
                analysisSiteArea(),
                // 应急避难场所面积
                analysisEmergencyShelterArea(),
                // 抗震等级
                analysisSeismicGrade(),
                // 结构形式
                analysisStructural(),
                // 不可回收组(构)件数量
                analysisNonRecyclable(),
                // 居住户数
                analysisHouseholds(),
                // 居住人数
                analysisNumberOfHouseholds(),
                // 人防所在层数
                analysisFloorOfPeopleAirDefence(),
                // 防护单元建筑面积
                analysisBuildingAreaOfProtectiveUnit(),
                // 战时出入口建筑面积
                analysisBuildingAreaOfWartimeEntrancesAndExits(),
                // 防倒塌棚架建筑面积
                analysisBuildingAreaOfAntiCollapseScaffolding(),
                // 其他可计入人防的建筑面积
                analysisOtherBuildingAreasOfCivilAirDefense(),
                // 消防车道
                analysisFireLane(),
                // 消防登高场地面积
                analysisAreaOfFirefightingClimbingSite(),
                // 消火栓位置
                analysisFireHydrantLocation(),
                // 能耗
                analysisEnergyConsumption(),
                // 声环境功能区防噪音设备位置
                analysisNoiseEquipment(),
                // 透水铺装面积比例
                analysisPermeablePavement(),
                // 雨水调蓄设施
                analysisStormwaterFacilities(),
                // 外排水径流系数
                analysisExternalDrainageRunoffCoefficient(),
                // 装配构件
                analysisAssemblyMember(),
                // 单体装配率
                analysisAssemblyRate(),
                // 整体装配率
                analysisOverallAssemblyRate(),
                // 设备能效指标
                analysisEquipmentIndex(),
                // 消防水源
                analysisFireWaterSource(),
                // 消防水源管径
                analysisWaterPipeDiameter(),
                // 消防水源容积
                analysisVolumeOfWaterSource(),
                // 消防水源供水压力
                analysisPressureOfSupplyWater(),
                // 消防设计用水量
                analysisFireProtectionDesignWaterConsumption(),
                // 给水用水量
                analysisWaterConsumptionForWaterSupply(),
                // 再生水用水量
                analysisRegeneratedWaterConsumption(),
                // 给水水压
                analysisFeedWaterPressure(),
                // 给水水源
                analysisWaterSource(),
                // 给水水源接入管径
                analysisWaterSourcePipeDiameter(),
                // 废水量
                analysisWasteWaterVolume(),
                // 污水量
                analysisSewageVolume(),
                // 分区设计小时耗热量
                analysisHourlyHeatConsumptionInZoningDesign(),
                // 最高日热水用量
                analysisMaximumDailyHotWaterConsumption(),
                // 热水系统热源                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                analysisHotWaterSystem(),
                // 热水系统供应方式
                analysisHotWaterSupplyMode(),
                // 热水系统供应部位
                analysisHotWaterSupplySite(),
                // 供电电源
                analysisPowerSupply(),
                // 进户高压电缆规格
                analysisHighVoltageCable(),
                // 应急电源功率
                analysisEmergencyPower(),
                // 应急电源容量
                analysisEmergencyPowerCapacity(),
                // 变配电室设备安装型号
                analysisDistributionRoomModel(),
                // 变配电室设备安装容量
                analysisDistributionRoomCapacity(),
                // 建筑物防雷
                analysisBuildingLightningProtector(),
                // 可再生能源比例
                analysisRenewableEnergyRatio(),

            };
        }

        // 进度变化
        private void BackWorkOnProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            Label1.Content = "审核中...(" + Convert.ToString(e.UserState) + ")";
            // ProgressBar.Value = e.ProgressPercentage;
        }

        // 执行完
        void backWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // 项目信息
            Document doc = UIApp.ActiveUIDocument.Document;
            ProjectInfo proj = doc.ProjectInformation;
            if (proj.get_Parameter(BuiltInParameter.PROJECT_NAME) != null)
                项目名称.Text = proj.get_Parameter(BuiltInParameter.PROJECT_NAME).AsString();
            if (proj.LookupParameter("项目编号") != null)
                项目编号.Text = proj.LookupParameter("项目编号").AsString();
            if (proj.LookupParameter("地块编号") != null)
                地块编号.Text = proj.LookupParameter("地块编号").AsString();
            //if (proj.LookupParameter("用地性质") != null)
            //    用地性质.Text = proj.LookupParameter("用地性质").AsString();
            //if (proj.LookupParameter("用地面积") != null)7
            //    用地面积.Text = proj.LookupParameter("用地面积").AsString();
            审查阶段.Text = "BIM5";
            审查时间.Text = DateTime.Now.ToString();
            审查类别.Text = "一般建筑";
            objectNameCode.Content = "审查对象及编码：" + 项目名称.Text + "__" + 项目编号.Text;

            // 自动审核指标数量
            var ReviewsCount = automaticReviewMetricsList.Count;
            // 自动备案指标数量
            var FilingsCount = automaticFilingMetricsList.Count;
            // 自动审核指标符合数量
            var ReviewsAccordCount = automaticReviewMetricsList.Where(r => "通过".Equals(r.result)).Count();
            // 自动审核指标异常数量
            var ReviewsAbnormalCount = automaticReviewMetricsList.Where(r => !"通过".Equals(r.result)).Count();
            // 自动备案指标符合数量
            var FilingsAccordCount = automaticFilingMetricsList.Where(r => "通过".Equals(r.result)).Count();
            // 自动备案指标异常数量
            var FilingsAbnormalCount = automaticFilingMetricsList.Where(r => !"通过".Equals(r.result)).Count();
            // 审查结论表数据
            conclusions = new List<conclusion>()
            {
                new conclusion()
                {
                    name = "自动审核指标",
                    count = ReviewsCount,
                    qualified = ReviewsAccordCount,
                    unqualified = ReviewsAbnormalCount
                },
                new conclusion()
                {
                    name = "自动备案指标",
                    count = FilingsCount,
                    qualified = FilingsAccordCount,
                    unqualified = FilingsAbnormalCount
                },
                new conclusion()
                {
                    name = "合计",
                    count = ReviewsCount + FilingsCount,
                    qualified = ReviewsAccordCount + FilingsAccordCount,
                    unqualified = ReviewsAbnormalCount + FilingsAbnormalCount
                },
        };

            // 结论
            var aa  = conclusions.FirstOrDefault(c => c.name == "合计")?.unqualified.ToString();
            int value = int.Parse(aa);
            if (value > 0)
            {
                conclusion.Text = $"有{value}条指标未通过";
            }
            else
            {
                conclusion.Text = $"全部通过";
            }

            RemarkTextBox.BorderThickness = new Thickness(0);  // 隐藏边框线

            if (canEditRemark)
            {
                RemarkTextBox.IsReadOnly = false;
            }
            else
            {
                RemarkTextBox.IsReadOnly = true;
            }
            // 视图展示
            // 自动审核指标
            AutomaticReviewMetrics.ItemsSource = automaticReviewMetricsList;
            // 自动备案指标
            AutomaticFilingMetrics.ItemsSource = automaticFilingMetricsList;
            // 审查结论表
            ConclusionListViewdDataGrid.ItemsSource = conclusions;

            progressBar.Visibility = Visibility.Collapsed;
            ScrollViewer_SHBG.Visibility = Visibility.Visible;
        }

        // 表格鼠标滚动事件
        private void DataGrid_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
            eventArg.RoutedEvent = UIElement.MouseWheelEvent;
            eventArg.Source = sender;
            var dg = (DataGrid)sender;
            dg.RaiseEvent(eventArg);
        }

        // 获取实例
        public static RealAndModel getInstance(UIApplication uiapp)
        {
            if (instance == null)
            {
                instance = new RealAndModel(uiapp);
            }

            return instance;
        }

        // 窗口关闭
        private void RealAndModel_OnClosed(object sender, EventArgs e)
        {
            instance = null;
            UIApp.Idling -= CheckLinkInsetanceResult;
        }
        // 关闭按钮
        private void CloseButton_OnClick(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private bool canEditRemark = false;

        // 修改按钮
        private void EditButton_OnClick(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;
            if ("修改".Equals(b.Content))
            {
                ConclusionListViewdDataGrid.IsReadOnly = false;
                AutomaticReviewMetrics.IsReadOnly = false;
                AutomaticFilingMetrics.IsReadOnly = false;
                b.Content = "保存";
                SolidColorBrush myBrush =
                    new SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x25, 0x56, 0x87));
                this.Background = (System.Windows.Media.Brush)myBrush;

                RemarkTextBox.BorderThickness = new Thickness(0);  // 隐藏边框线

                // 设置为可编辑状态
                canEditRemark = true;
                RemarkTextBox.IsReadOnly = false;
            }
            else if ("保存".Equals(b.Content))
            {
                ConclusionListViewdDataGrid.IsReadOnly = true;
                AutomaticReviewMetrics.IsReadOnly = true;
                AutomaticFilingMetrics.IsReadOnly = true;
                string newRemark = RemarkTextBox.Name ;  // 获取TextBox的值
                // MessageBox.Show("保存成功", "提示");
                b.Content = "修改";
                SolidColorBrush myBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));
                this.Background = (System.Windows.Media.Brush)myBrush;

                RemarkTextBox.BorderThickness = new Thickness(0);  // 隐藏边框线

                // 设置为只读状态
                canEditRemark = false;
                RemarkTextBox.IsReadOnly = true;

            }
        }
        // 指标表格双击事件
        private void MetricsViewdDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                DataGrid datagrid = sender as DataGrid;
                System.Windows.Point aP = e.GetPosition(datagrid);
                IInputElement obj = datagrid.InputHitTest(aP);
                DependencyObject target = obj as DependencyObject;
                while (target != null)
                {
                    if (target is DataGridRow)
                    {
                        UIDocument uiDoc = UIApp.ActiveUIDocument;
                        indicatorDetails id = datagrid.CurrentItem as indicatorDetails;
                        if (id != null && id.canDoubleClick)
                        {
                            var selection = uiDoc.Selection.GetElementIds();
                            if (selection.Count != 0)
                            {
                                selection.Clear();
                            }
                            uiDoc.Selection.SetElementIds(id.elementIds);
                            uiDoc.ShowElements(id.elementIds);
                            this.WindowState = WindowState.Minimized;
                        }
                        break;
                    }
                    target = VisualTreeHelper.GetParent(target);
                }
            }
            catch (Exception)
            {

            }
        }

        #region 指标信息提取

        // 用地红线
        private indicatorDetails analysisRedLine()
        {
            backWork.ReportProgress(0, "用地红线");
            
            indicatorDetails indicator = new indicatorDetails();
            
            var collector = new FilteredElementCollector(doc);
            List<ElementId> elements = new List<ElementId>();

            collector.OfCategory(BuiltInCategory.OST_SiteProperty).OfClass(typeof(PropertyLine));
            
            foreach (Element elem in collector.ToElements())
            {
                Parameter name = elem.get_Parameter(BuiltInParameter.ROOM_NAME);
                
                if (name != null && name.AsString() != null && name.AsString().Contains("建筑红线"))
                {
                    Parameter area = elem.get_Parameter(BuiltInParameter.PROPERTY_AREA);
                    indicator.designValue =
                        Math.Round(UnitUtils.ConvertFromInternalUnits(area.AsDouble(), area.DisplayUnitType), 3)
                    .ToString() + "(照片)";
                    elements.Add(elem.Id);

                    Location location = elem.Location;
                    // var origin = ((Line)((LocationCurve)location).Curve).Origin;


                    break;
                }
            }

            indicator.name = "用地红线";

            indicator.tolerance = "+1cm";

            indicator.planningControlValue = "30%";
            indicator.result = "不通过";
            if (elements.Count != 0)
            {
                indicator.canDoubleClick = true;
                indicator.elementIds = elements;
            }

            return indicator;
        }

        // 地上建筑边界
        private indicatorDetails analysisBuildingRetreat()
        {
            backWork.ReportProgress(0, "地上建筑退界");
            indicatorDetails indicator = new indicatorDetails();

            indicator.result = "不通过";
            indicator.name = "地上建筑退界";

            return indicator;
        }

        // 地块主功能建筑面积占比
        private indicatorDetails analysisUnderground()
        {
            backWork.ReportProgress(0, "地块主功能建筑面积占比");
            indicatorDetails indicator = new indicatorDetails();

            indicator.result = "不通过";
            indicator.name = "地块主功能建筑面积占比";

            return indicator;
        }


        //// 主功能建筑面积
        //private indicatorDetails analysisBuildingRoomArea()
        //{
        //    backWork.ReportProgress(0, "主功能建筑面积");
        //    FilteredElementCollector collector = new FilteredElementCollector(doc);
        //    ElementClassFilter LinkFilter = new ElementClassFilter(typeof(RevitLinkInstance));
        //    FilteredElementIterator linkIterator = collector.WherePasses(LinkFilter).GetElementIterator();
        //    indicatorDetails indicator = new indicatorDetails();
        //    double area = 0;
        //    while (linkIterator.MoveNext())
        //    {
        //        RevitLinkInstance LinkInstance = linkIterator.Current as RevitLinkInstance;
        //        Document LinkDoc = LinkInstance.GetLinkDocument();
        //        if (LinkDoc == null) continue;
        //        var collector1 = new FilteredElementCollector(LinkDoc);
        //        collector1.OfCategory(BuiltInCategory.OST_Rooms);
        //        foreach (Element elem in collector1.ToElements())
        //        {
        //            Room room = elem as Room;
        //            if (room == null) continue;
        //            Parameter RoomAREA = room.get_Parameter(BuiltInParameter.ROOM_AREA);
        //            if (RoomAREA != null)
        //                area += UnitUtils.ConvertFromInternalUnits(RoomAREA.AsDouble(), RoomAREA.DisplayUnitType);
        //        }
        //    }

        //    indicator.name = "主功能建筑面积";
        //    indicator.designValue = Math.Round(area, 3).ToString();



        //    return indicator;
        //}



        // 主功能建筑面积
        private indicatorDetails analysisBuildingRoomArea()
        {
            backWork.ReportProgress(0, "主功能建筑面积");

            // 创建一个indicatorDetails对象，用于存储分析结果  
            indicatorDetails indicator = new indicatorDetails();
            // 创建一个StringBuilder对象，用于拼接字符串  
            StringBuilder sb = new StringBuilder();
            // 初始化计数器i为1  
            int i = 1;
            // 创建一个FilteredElementCollector对象，用于从文档中收集链接的实例  
            // 这个方法需要传入两个参数：doc（文档）和类型（RevitLinkInstance）  
            // 结果将存储在coll中  
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));

            // 遍历所有链接文档（RevitLinkInstance）  
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                // 获取链接文档（RevitLinkInstance）的链接文档  
                Document LinkDoc = LinkInstance.GetLinkDocument();
                // 如果链接文档为空，则跳过此次循环  
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(doc);
                collector.OfClass(typeof(SpatialElement));
                var rooms = collector.ToElements().OfType<Room>();
                double totalArea = 0;

                foreach (Room elem in collector.ToElements())
                {
                    // 获取房间元素的面积参数  
                    Parameter areaParam = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                    // 将房间的面积参数取值转换为平方米单位  
                    double area = UnitUtils.ConvertFromInternalUnits(areaParam.AsDouble(), DisplayUnitType.DUT_SQUARE_METERS);

                    totalArea += area;
                }
                // 将计数器i的值、总面积（以平方米为单位）以及一个换行符拼接到StringBuilder对象中  
                sb.Append("[" + i++ + "] ");
                sb.Append(totalArea.ToString("0.00") + "平方米");
                // 如果还有其他链接文档（RevitLinkInstance）未处理，则在拼接的字符串后面添加一个换行符  
                if (coll.ToElements().Count + 1 != i)
                    sb.Append("\n");
            }
            indicator.name = "主功能建筑面积";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";

            return indicator;
        }




        // 容积率
        private indicatorDetails analysisPlotRatio()
        {
            // 总建筑面积
            string kok =  analysisOverallFloorage().designValue;
            double pop = Double.Parse(kok);

            backWork.ReportProgress(0, "容积率");

            indicatorDetails indicator = new indicatorDetails();

            // StringBuilder sb = new StringBuilder();

            int i = 1;
            double totalArea = 0;  // 添加一个变量用于保存总面积
            double rongjilv = 0;

            var linkInstances = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkInstance)).ToElements();

            foreach (RevitLinkInstance linkInstance in linkInstances)
            {
                Document linkDoc = linkInstance.GetLinkDocument();
                if (linkDoc == null) continue;

                var collector = new FilteredElementCollector(linkDoc).OfClass(typeof(SpatialElement)).OfType<Room>();

                double area = 0; // 每个链接实例的土地面积

                foreach (Room room in collector)
                {
                    Parameter areaParam = room.get_Parameter(BuiltInParameter.ROOM_AREA);
                    double roomArea = UnitUtils.ConvertFromInternalUnits(areaParam.AsDouble(), DisplayUnitType.DUT_SQUARE_METERS);
                    area += roomArea;
                }
                totalArea += area; // 累加到总面积上

            }

            rongjilv = pop / totalArea;

            double roundedRongjilv = Math.Round(rongjilv, 2);

            string result = $"{roundedRongjilv:F2}%";


            indicator.name = "容积率";
            indicator.designValue = result.ToString();
            indicator.result = "不通过";

            return indicator;
        }


        // 绿地率
        private indicatorDetails analysisGreenspaceRate()
        {
            backWork.ReportProgress(0, "绿地率");
            
            // 创建了一个名为 indicator 的 indicatorDetails 对象，用于保存指标的详细信息。
            indicatorDetails indicator = new indicatorDetails();
            // 创建了一个 FilteredElementCollector 对象，用于收集文档中的元素。
            var collector = new FilteredElementCollector(doc);
            // 使用.OfCategory 和 .OfClass 方法来过滤收集器中的元素，只保留类别为 OST_Topography 并且类型为 TopographySurface 的元素。
            collector.OfCategory(BuiltInCategory.OST_Topography).OfClass(typeof(TopographySurface));
            // 定义了一个名为 greenSpaceArea 的变量，用于保存绿地的总面积。初始值为 0。
            double greenSpaceArea = 0;
            // 使用 foreach 循环遍历收集器中的每个元素。
            foreach (Element elem in collector.ToElements())
            {
                // 获取当前元素的名为 “ROOM_NAME” 的参数，并将其赋值给 elName 变量。
                var elName = elem.get_Parameter(BuiltInParameter.ROOM_NAME);
                // 检查 elName 变量是否存在，并且其值是否等于 “绿地” 字符串。
                if (elName != null && "绿地".Equals(elName.AsString()))
                {
                    // 获取当前元素的名为 “PROJECTED_SURFACE_AREA” 的参数，并将其赋值给 area 变量。
                    var area = elem.get_Parameter(BuiltInParameter.PROJECTED_SURFACE_AREA);
                    // 检查 area 变量是否存在。
                    if (area != null)
                    {
                        // 将 area 参数的值从内部单位转换为显示单位，并将转换后的值加到 greenSpaceArea 变量上。
                        greenSpaceArea += UnitUtils.ConvertFromInternalUnits(area.AsDouble(), area.DisplayUnitType);
                    }
                }
            }
            // 建筑红线
            // 创建了一个新的 FilteredElementCollector 对象，并将其赋值给 collector 变量。
            collector = new FilteredElementCollector(doc);
            // 使用.OfCategory 和 .OfClass 方法来过滤收集器中的元素，只保留类别为 OST_SiteProperty 并且类型为 PropertyLine 的元素。
            collector.OfCategory(BuiltInCategory.OST_SiteProperty).OfClass(typeof(PropertyLine));
            // 定义了一个名为 landUserArea 的变量，用于保存用地面积。初始值为 1。
            double landUserArea = 1;
            // 使用 foreach 循环遍历收集器中的每个元素。
            foreach (Element elem in collector.ToElements())
            {
                // 获取当前元素的名为 “ROOM_NAME” 的参数，并将其赋值给 name 变量。
                Parameter name = elem.get_Parameter(BuiltInParameter.ROOM_NAME);
                // 检查 name 变量是否存在，并且其值非空且包含 “红线” 字符串。
                if (name != null && name.AsString() != null && name.AsString().Contains("红线"))
                {
                    // 获取当前元素的名为 “PROPERTY_AREA” 的参数，并将其赋值给 area 变量。
                    Parameter area = elem.get_Parameter(BuiltInParameter.PROPERTY_AREA);
                    // 将 area 参数的值从内部单位转换为显示单位，并将转换后的值赋值给 landUserArea。
                    landUserArea = UnitUtils.ConvertFromInternalUnits(area.AsDouble(), area.DisplayUnitType);
                    // 终止 foreach 循环，只处理第一个满足条件的元素。
                    break;
                }
            }
            // 将指标的名称设置为 “绿地率”。
            indicator.name = "绿地率";
            // 计算绿地率，并将结果设置为 designValue，通过将绿地面积除以用地面积并乘以 100，然后使用 Math.Round 方法进行四舍五入处理。
            indicator.designValue = Math.Round(greenSpaceArea / landUserArea * 100, 3) + "%";

            // 将计划控制值设置为 “30 %”。
            indicator.planningControlValue = "30%";
            // 将允许误差范围设置为 “±5 %”。
            indicator.tolerance = "±5%";

             // 计算绿地率，并将结果设置为 designValue，通过将绿地面积除以用地面积并乘以 100，然后使用 Math.Round 方法进行四舍五入处理。
            indicator.designValue = Math.Round(greenSpaceArea / landUserArea * 100, 3) + "%";

            Double myFloat = Math.Round(greenSpaceArea / landUserArea * 100, 3);

            // 将计划控制值设置为 “30 %”。
            indicator.planningControlValue = "30%";
            // 将允许误差范围设置为 “±5 %”。
            indicator.tolerance = "±5%";

            if (myFloat > 35 || myFloat < 25)
            {
                indicator.result = "不通过";
            }
            else
            {
                indicator.result = "通过";
            }

            // 将结果设置为 “通过”。
            // indicator.result = "不通过";
            // 返回 indicator 对象，该对象保存了指标的详细信息。
            return indicator;
        }



        // 建筑密度
        private indicatorDetails analysisBuildingDensity()
        {
            backWork.ReportProgress(0, "建筑密度");

            indicatorDetails indicator = new indicatorDetails();
            decimal totalArea = 0;
            int linkModelIndex = 1;
            List<string> strings = new List<string>();

            // 获取所有Revit链接实例
            FilteredElementCollector revitLinkCollector = new FilteredElementCollector(doc);
            revitLinkCollector.OfClass(typeof(RevitLinkInstance));

            foreach (RevitLinkInstance linkInstance in revitLinkCollector.ToElements())
            {
                Document linkDoc = linkInstance.GetLinkDocument();
                if (linkDoc == null) continue;

                // 获取链接文档中的底层房间
                FilteredElementCollector roomCollector = new FilteredElementCollector(linkDoc);
                roomCollector.OfCategory(BuiltInCategory.OST_Rooms);

                decimal linkModelArea = 0;
                foreach (Element elem in roomCollector.ToElements())
                {
                    Room room = elem as Room;
                    if (room == null) continue;

                    // 获取房间面积
                    double roomArea = room.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble();
                    decimal areaInSquareFeet = (decimal)UnitUtils.ConvertFromInternalUnits(roomArea, DisplayUnitType.DUT_SQUARE_FEET);

                    linkModelArea += areaInSquareFeet;
                }

                totalArea += linkModelArea;

                // 根据规划建设用地的特定参数获取面积，具体根据Revit文档中的元素类型和参数进行修改
                // 示例：获取参数名为"Planned Construction Area"的规划建设用地面积
                FilteredElementCollector areaCollector = new FilteredElementCollector(linkDoc);
                List<Element> areas = areaCollector.OfCategory(BuiltInCategory.OST_Areas)
                                                   .WhereElementIsNotElementType()
                                                   .ToList();

                Parameter areaParameter = null;
                foreach (Element area in areas)
                {
                    areaParameter = area.LookupParameter("Planned Construction Area");
                    if (areaParameter != null) break;
                }

                if (areaParameter != null && areaParameter.StorageType == StorageType.Double)
                {
                    double areaValue = areaParameter.AsDouble();
                    decimal areaInSquareFeet = (decimal)UnitUtils.ConvertFromInternalUnits(areaValue, DisplayUnitType.DUT_SQUARE_FEET);

                    // 计算建筑密度
                    decimal buildingDensity = linkModelArea / areaInSquareFeet;
                    strings.Add("链接模型：" + linkInstance.Name + "，建筑密度：" + buildingDensity.ToString());
                }

                linkModelIndex++;
            }

            strings.Insert(0, ""+ totalArea.ToString());

            string designValue = string.Join("\n", strings);

            indicator.name = "建筑密度";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 地上总建筑面积
        private indicatorDetails analysisUpOverallFloorage()
        {
            backWork.ReportProgress(0, "地上总建筑面积");
            decimal totalArea = 0;
            indicatorDetails indicator = new indicatorDetails();

            FilteredElementCollector revitLinkCollector = new FilteredElementCollector(doc);
            revitLinkCollector.OfClass(typeof(RevitLinkInstance));

            foreach (RevitLinkInstance linkInstance in revitLinkCollector.ToElements())
            {
                Document linkDoc = linkInstance.GetLinkDocument();
                if (linkDoc == null) continue;

                var wallCollector = new FilteredElementCollector(linkDoc);
                wallCollector.OfCategory(BuiltInCategory.OST_Walls);

                foreach (Element wallElement in wallCollector)
                {
                    Wall wall = wallElement as Wall;
                    if (wall == null) continue;

                    if (wall.LevelId == ElementId.InvalidElementId) continue; // 添加空值检查
                    Element levelElement = linkDoc.GetElement(wall.LevelId);
                    if (levelElement == null) continue; // 修改1：当效楼层元素时跳过本次迭代

                    Level level = levelElement as Level;

                    double wallHeight = wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble();

                    FilteredElementCollector viewCollector = new FilteredElementCollector(doc);
                    viewCollector.OfClass(typeof(View));
                    View specificView = viewCollector.FirstOrDefault() as View;
                    if (specificView == null)
                    {
                        throw new ArgumentNullException("specificView", "未找到有效的视图对象");
                        // 或者使用其他处理逻辑
                    }

                    Options options = new Options
                    {
                        View = specificView
                    };

                    GeometryElement geometry = wall.get_Geometry(options);
                    if (geometry == null) continue;
                    foreach (GeometryObject obj in geometry)
                    {
                        if (obj is Solid solid)
                        {
                            FaceArray faces = solid.Faces;
                            foreach (Face face in faces)
                            {
                                PlanarFace planarFace = face as PlanarFace;
                                if (planarFace != null && planarFace.FaceNormal.Z == 1.0)  // 确保面朝上 (Z 分量等于 1)
                                {
                                    double projectedArea = face.Area;  // 获取面的投影面积
                                    decimal levelWallArea = (decimal)(projectedArea * wallHeight); // 考虑墙的高度计算面积
                                    totalArea += levelWallArea;
                                }

                            }
                        }
                    }
                }
            }

            indicator.name = "地上总建筑面积";
            indicator.designValue = Math.Round(totalArea, 2).ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 地下总建筑面积
        private indicatorDetails analysisBelowOverallFloorage()
        {
            backWork.ReportProgress(0, "地下总建筑面积");
            decimal totalArea = 0;
            indicatorDetails indicator = new indicatorDetails();

            // 获取所有Revit实例
            FilteredElementCollector revitLinkCollector = new FilteredElementCollector(doc);
            revitLinkCollector.OfClass(typeof(RevitLinkInstance));

            foreach (RevitLinkInstance linkInstance in revitLinkCollector.ToElements())
            {
                Document linkDoc = linkInstance.GetLinkDocument();
                if (linkDoc == null) continue;

                var wallCollector = new FilteredElementCollector(linkDoc);
                wallCollector.OfCategory(BuiltInCategory.OST_Walls);

                foreach (Element wallElement in wallCollector)
                {
                    Wall wall = wallElement as Wall;
                    if (wall == null) continue;

                    if (wall.LevelId == ElementId.InvalidElementId) continue; // 添加空值检查
                    Element levelElement = linkDoc.GetElement(wall.LevelId);
                    if (levelElement == null) continue; // 修改1：当效楼层元素时跳过本次迭代

                    Level level = levelElement as Level;

                    double wallHeight = wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble();

                    FilteredElementCollector viewCollector = new FilteredElementCollector(doc);
                    viewCollector.OfClass(typeof(View));
                    View specificView = viewCollector.FirstOrDefault() as View;
                    if (specificView == null)
                    {
                        throw new ArgumentNullException("specificView", "未找到有效的视图对象");
                        // 或者使用其他处理逻辑
                    }

                    Options options = new Options
                    {
                        View = specificView
                    };

                    GeometryElement geometry = wall.get_Geometry(options);
                    if (geometry == null) continue;
                    foreach (GeometryObject obj in geometry)
                    {
                        if (obj is Solid solid)
                        {
                            FaceArray faces = solid.Faces;
                            foreach (Face face in faces)
                            {
                                PlanarFace planarFace = face as PlanarFace;
                                if (planarFace != null && planarFace.FaceNormal.Z == -1.0)  // 确保面朝下 (Z 分量等于 -1)
                                {
                                    double projectedArea = face.Area;
                                    decimal levelWallArea = (decimal)(projectedArea * wallHeight);
                                    totalArea += levelWallArea;
                                }
                            }
                        }
                    }
                }
            }

            indicator.name = "地下总建筑面积";
            indicator.designValue = Math.Round(totalArea, 2).ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 总建筑面积
        private indicatorDetails analysisOverallFloorage()
        {
            backWork.ReportProgress(0, "总建筑面积");
            string upFloorage = analysisUpOverallFloorage().designValue;
            string belowFloorage = analysisBelowOverallFloorage().designValue;

            decimal upFloorageValue;
            decimal belowFloorageValue;
            decimal totalFloorage = 0;

            if (decimal.TryParse(upFloorage, out upFloorageValue)
                && decimal.TryParse(belowFloorage, out belowFloorageValue))
            {
                totalFloorage = upFloorageValue + belowFloorageValue;
            }

            indicatorDetails indicator = new indicatorDetails();
            indicator.name = "总建筑面积";
            indicator.designValue = Math.Round(totalFloorage, 2).ToString();
            indicator.result = "不通过";

            return indicator;
        }


        // 计容建筑面积
        private indicatorDetails analysisCapacityArea()
        {
            backWork.ReportProgress(0, "计容建筑面积");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            
            decimal building_area = 0;
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Rooms);
                string value = string.Empty;
                List<spaceInfo> spaceInfos = new List<spaceInfo>();
                foreach (Element elem in collector.ToElements())
                {
                    Room room = elem as Room;
                    if (room == null) continue;
                    spaceInfo space = new spaceInfo();

                    space.id = elem.Id.ToString(); // ID
                    Parameter RoomAREA = room.get_Parameter(BuiltInParameter.ROOM_AREA);
                    if (RoomAREA != null)
                        building_area = (decimal)Math.Round(UnitUtils.ConvertFromInternalUnits(RoomAREA.AsDouble(), RoomAREA.DisplayUnitType), 3); // 面积
                    if (room.LookupParameter("计容面积") != null)
                        space.capacity_area = (decimal)Math.Round(UnitUtils.ConvertFromInternalUnits(elem.LookupParameter("计容面积").AsDouble(), RoomAREA.DisplayUnitType), 3);
                    spaceInfos.Add(space);
                }

                foreach (spaceInfo space in spaceInfos)
                {
                    if (!string.IsNullOrEmpty(space.equipment_capacity))
                    {
                        // 将capacity_area添加到字符串中
                        strings.Add("[" + j + "] " + " (Capacity Area: " + space.capacity_area.ToString() + ")");
                        j++;
                    }
                }
            }

            string designValue = string.Join("\n", strings);

            indicator.name = "计容建筑面积";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 场地标高
        private indicatorDetails analysisSiteLevels()
        {
            backWork.ReportProgress(0, "场地标高");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            // 获取链接文档
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Levels).OfClass(typeof(Level));
                Level targetLevel = null;
                foreach (Level elem in collector.ToElements())
                {
                    Parameter levelCode = elem.LookupParameter("楼层编号");
                    if ((levelCode != null && "1F".Equals(levelCode.AsString())) || (elem.Name != null && elem.Name.Equals("1F_0.000")))
                    {
                        targetLevel = elem;
                        break;
                    }
                }
                if (targetLevel == null) continue;
                // Decimal absoluteHeight = ChangeDataToD((targetLevel.Elevation).ToString());
                double absoluteHeight = UnitUtils.ConvertFromInternalUnits(targetLevel.Elevation, DisplayUnitType.DUT_METERS);

                sb.Append("[" + i++ + "] ");
                sb.Append(absoluteHeight.ToString("0.00") + "米");
                if (coll.ToElements().Count + 1 != i)
                    sb.Append("\n");

            }
            indicator.name = "场地标高";

            indicator.tolerance = "±1cm";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 建筑(构筑物)高度
        private indicatorDetails analysisBuildingHeight()
        {
            backWork.ReportProgress(0, "建筑(构筑物)高度");

            indicatorDetails indicator = new indicatorDetails();

            indicator.name = "建筑(构筑物)高度";

            indicator.tolerance = "5%(含5%)";
            indicator.result = "不通过";

            return indicator;
        }

        // 地下建筑范围
        private indicatorDetails analysisBelowBuildingZone()
        {
            backWork.ReportProgress(0, "地下建筑范围");

            indicatorDetails indicator = new indicatorDetails();

            indicator.name = "地下建筑范围";
            indicator.result = "不通过";

            return indicator;
        }

        //地下建筑标高
        private indicatorDetails analysisBelowBuildingElevation()
        {
            backWork.ReportProgress(0, "地下建筑标高"); // 修改进度报告信息

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Floors).OfClass(typeof(Floor));
                string value = string.Empty;
                List<slabs> balconies = new List<slabs>();
                foreach (Element elem in collector.ToElements())
                {
                    Floor floor = elem as Floor;
                    if (floor == null) continue;
                    slabs s = new slabs();
                    s.Id = elem.Id.ToString();
                    balconies.Add(s);

                    // 检索标高参数值
                    Parameter levelParam = floor.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM);
                    if (levelParam != null)
                    {
                        double elevation = levelParam.AsDouble(); // 获取标高值

                        if (elevation < 0) // 判断标高值是否为地下板
                        {
                            value = "[" + j + "] ";
                            value += elevation.ToString() + " "; // 将地下板标高值转换为字符串并添加到值中
                        }
                    }
                }
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "地下建筑标高"; // 修改指标名称
            indicator.tolerance = "±20cm"; // 地下板标高没有公认的容差范围，将其设为N/A
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 配建公共服务设施类型
        private indicatorDetails analysisTypesOfPublicServiceFacilities()
        {
            backWork.ReportProgress(0, "配建公共服务设施类型");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Rooms);
                string value = string.Empty;
                foreach (Element elem in collector.ToElements())
                {
                    Parameter type = elem.LookupParameter("主功能类别");
                    if (type != null && "居住配套管理".Equals(type.AsString()))
                    {
                        Parameter sunType = elem.LookupParameter("子功能类别");
                        if (sunType != null)
                        {
                            value = "[" + j + "] ";
                            value += sunType.AsString() + " ";
                        }
                    }
                }
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "配建公共服务设施类型";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 配建公共服务设施规模
        private indicatorDetails analysisAreaOfPublicServiceFacilities()
        {
            backWork.ReportProgress(0, "配建公共服务设施规模");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                double roomArea = 0;
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Rooms);
                foreach (Element elem in collector.ToElements())
                {
                    Room room = elem as Room;
                    if (room == null) continue;
                    Parameter type = elem.LookupParameter("主功能类别");
                    if (type != null && "居住配套管理".Equals(type.AsString()))
                    {
                        Parameter RoomAREA = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                        if (RoomAREA != null)
                            roomArea += UnitUtils.ConvertFromInternalUnits(RoomAREA.AsDouble(), RoomAREA.DisplayUnitType); // 面积
                    }
                    strings.Add("[" + j + "] 居住配套管理:" + roomArea.ToString("0.000"));
                }
                j++;
            }

            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue = strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "配建公共服务设施规模";

            indicator.tolerance = "≥规划管控制";

            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 配建公共服务设施位置
        private indicatorDetails analysisPositionOfPublicServiceFacilities()
        {
            backWork.ReportProgress(0, "配建公共服务设施位置");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            List<ElementId> elementIds = new List<ElementId>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.WhereElementIsNotElementType();
                int i = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Parameter Non_recyclable = elem.LookupParameter("子功能类别");
                    if (Non_recyclable != null && Non_recyclable.AsString() != null && Non_recyclable.AsString().Contains("公共服务设施"))
                    {
                        elementIds.Add(elem.Id);
                        i++;
                    }
                }
                strings.Add("[" + j++ + "] " + i);
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "配建公共服务设施位置";
            indicator.designValue = designValue;
            indicator.canDoubleClick = true;

            indicator.elementIds = elementIds;
            indicator.result = "不通过";
            return indicator;
        }

        // 地铁机车出入口
        private indicatorDetails analysisSubwayEntrance()
        {
            backWork.ReportProgress(0, "地块机车出入口");

            indicatorDetails indicator = new indicatorDetails();
            string designValue = string.Empty;


            var collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
            List<gate> gates = new List<gate>();
            foreach (Element elem in collector.ToElements())
            {
                gate g = new gate();
                if (elem.Name != null && elem.Name.Contains("机动车出入口"))
                {

                    Parameter type = elem.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM);
                    if (type.AsValueString() != null && type.AsValueString().Contains("机动车出入口"))
                    {
                        Parameter name = elem.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM);
                        if (name != null)
                            g.name = name.AsValueString();

                        // 将获取到的值拼接到designValue字符串中
                        if (!string.IsNullOrEmpty(g.name))
                            designValue += g.name + ";";
                    }
                    
                }
                gates.Add(g);
            }


            indicator.name = "地块机车出入口";
            indicator.designValue = designValue.TrimEnd(';');
            indicator.result = "不通过";
            return indicator;
        }



        // 公共通道
        private indicatorDetails analysisCommonAisle()
        {
            backWork.ReportProgress(0, "公共通道");

            List<road> roads = new List<road>();
            var collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));

            foreach (Element elem in collector.ToElements())
            {
                if (elem.LookupParameter("道路类别") != null && elem.LookupParameter("道路类别").AsString() != null && elem.LookupParameter("道路类别").AsString().Contains("公共通道"))
                {
                    road road = new road();
                    road.Id = elem.Id.ToString();
                    if (elem.LookupParameter("道路名称") != null)
                        road.name = elem.LookupParameter("道路名称").AsString();
                    roads.Add(road);
                }
            }

            indicatorDetails indicator = new indicatorDetails();

            indicator.name = "公共通道";

            if (roads.Count > 0)
            {
                indicator.designValue = roads[0].name;
            }
            indicator.result = "不通过";
            return indicator;
        }


        // 机动车停车位数量
        private indicatorDetails analysisParkingSpotCount()
        {
            backWork.ReportProgress(0, "机动车停车位数量");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "机动车停车位数量";
            indicator.result = "不通过";

            return indicator;
        }

        // 非机动车停车面积

        private indicatorDetails analysisNonMotorParking()
        {

            var collectortwo = new FilteredElementCollector(doc);
            collectortwo.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
            double emergencyShelterArea = 0;
            foreach (Element elem in collectortwo.ToElements())
            {
                if (elem.Name != null && elem.Name.Contains("场地"))
                {
                    var flag = elem.LookupParameter("场地类型");
                    if (flag != null && flag.AsString() != null && flag.AsString().Contains("非机动车停车场"))
                    {
                        var area = elem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);// 面积
                        if (area != null)
                            emergencyShelterArea += UnitUtils.ConvertFromInternalUnits(area.AsDouble(), area.DisplayUnitType);
                    }

                }
            }


            backWork.ReportProgress(0, "非机动车停车面积");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                double roomArea = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("功能分区类别");
                    if (type != null && type.AsString() != null && type.AsString().Contains("非机动车停车场"))
                    {
                        var room_area = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                        if (room_area != null)
                            roomArea += UnitUtils.ConvertFromInternalUnits(room_area.AsDouble(), room_area.DisplayUnitType); // 面积
                        
                    }
                }
                roomArea += emergencyShelterArea;
                strings.Add("[" + j + "] "  + roomArea.ToString("0.000"));
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "非机动车停车面积";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 战时功能
        private indicatorDetails analysisWartimeFunction()
        {
            backWork.ReportProgress(0, "战时功能");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("人防工程类别");
                    if (type != null && type.AsString() != null)
                    {

                        value = "[" + j + "] ";
                        value += type.AsString() + " ";
                    }
                }
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "战时功能";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }
        // 抗力等级
        private indicatorDetails analysisResistanceLevel()
        {
            backWork.ReportProgress(0, "抗力等级");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("人防抗力等级");
                    if (type != null && type.AsString() != null )
                    {
                       
                            value = "[" + j + "] ";
                            value += type.AsString() + " ";
                    }
                }
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "抗力等级";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 防化级别
        private indicatorDetails analysisChemicalPreventionLevel()
        {
            backWork.ReportProgress(0, "防化级别");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;


            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("防化等级");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }

            }
            indicator.name = "防化等级";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 人防总建筑面积
        private indicatorDetails analysisCivilAirDefenseBuildingArea()
        {
            backWork.ReportProgress(0, "人防总建筑面积");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                double roomArea = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("功能分区类别");
                    if (type != null && type.AsString() != null && type.AsString().Contains("人防分区"))
                    {
                        var room_area = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                        if (room_area != null)
                            roomArea += UnitUtils.ConvertFromInternalUnits(room_area.AsDouble(), room_area.DisplayUnitType); // 面积
                    }
                }
                strings.Add("[" + j + "] " + roomArea.ToString("0.000"));
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "人防总建筑面积";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 植物配置
        private indicatorDetails analysisBotany()
        {
            backWork.ReportProgress(0, "植物配置");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "植物配置";
            indicator.result = "不通过";

            return indicator;
        }

        // 贴线率
        private indicatorDetails analysisAttachmentRate()
        {
            backWork.ReportProgress(0, "贴线率");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "贴线率";
            indicator.result = "不通过";

            return indicator;
        }

        // 坡屋顶比例
        private indicatorDetails analysisSlopeRoofRatio()
        {
            backWork.ReportProgress(0, "坡屋顶比例");

            double po_mianji = 0;
            double zo_mianji = 0;

            string value = string.Empty;
            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Roofs).OfClass(typeof(FootPrintRoof));
                foreach (Element elem in collector.ToElements())
                {
                    if (elem.LookupParameter("面积") != null)
                    {
                        double mianji = elem.LookupParameter("面积").AsDouble();
                        if (elem.Name.Contains("坡屋顶"))
                        {
                            po_mianji += mianji;
                        }
                        zo_mianji += mianji;
                    }
                }
            }

            double zongmianji = po_mianji / zo_mianji;

            value = "[" + j + "] ";
            value += Math.Round(zongmianji, 2).ToString("P");
            if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
            {
                strings.Add(value);
            }

            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "坡屋顶比例";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 建筑(整体)窗墙比
        private indicatorDetails analysisWindowWallRatio()
        {


            backWork.ReportProgress(0, "建筑(整体)窗墙比");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));

            double winmianji = 0;
            double winmianjihe = 0;

            double wellmianji = 0;
            double wellmianjihe = 0;
            double ratio = 0;

            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Windows).OfClass(typeof(FamilyInstance));
                List<window> windows = new List<window>();
                foreach (Element elem in collector.ToElements())
                {
                    window window = new window();
                    window.Id = elem.Id.ToString();

                    
                    if (elem.LookupParameter("面积") != null)
                        winmianji = elem.LookupParameter("面积").AsDouble();

                    winmianjihe += winmianji;
                }
            }


            string value = string.Empty;
            var colltwo = new FilteredElementCollector(doc);
            colltwo.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in colltwo.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collectortwo = new FilteredElementCollector(LinkDoc);
                collectortwo.OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(Wall));
                
                List<walls> wallsList = new List<walls>();
                foreach (Element elem in collectortwo.ToElements())
                {
                    Wall wall = elem as Wall;
                    if (wall == null) continue;
                    walls w = new walls();
                    w.Id = elem.Id.ToString();

                    if (wall.LookupParameter("面积") != null)
                        wellmianji = elem.LookupParameter("面积").AsDouble();
                    wellmianjihe += wellmianji;
                }

                ratio = winmianjihe / wellmianjihe;
                value = "[" + j + "] ";
                value += Math.Round(ratio, 2).ToString("P");
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }

            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "建筑(整体)窗墙比";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 建筑室外设备
        private indicatorDetails analysisOutdoorEquipment()
        {
            backWork.ReportProgress(0, "建筑室外设备");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            List<ElementId> elementIds = new List<ElementId>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.WhereElementIsNotElementType();
                int i = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Parameter Non_recyclable = elem.LookupParameter("是否为室外构件");
                    if (Non_recyclable != null && Non_recyclable.AsInteger() == 1)
                    {
                        elementIds.Add(elem.Id);
                        i++;
                    }
                }
                strings.Add("[" + j++ + "] " + i);
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "建筑室外设备";
            indicator.designValue = designValue;
            indicator.canDoubleClick = true;
            indicator.elementIds = elementIds;
            indicator.result = "不通过";
            return indicator;
        }

        // 独立站、机房
        private indicatorDetails analysisIndependentStation()
        {

            backWork.ReportProgress(0, "独立站、机房");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int j = 1;

            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));

            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;

                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Rooms);

                List<string> strings = new List<string>();

                foreach (Element elem in collector.ToElements())
                {
                    Room room = elem as Room;
                    if (room == null) continue;

                    string function = room.LookupParameter("房间功能")?.AsString();
                    if (function != null && (function.Contains("独立站") || function.Contains("机房")))
                    {
                        strings.Add("[" + j + "] " + function + " in room " + elem.Id.ToString());
                        j++;
                    }
                }

                sb.Append(string.Join("\n", strings) + "\n");
            }

            indicator.name = "独立站、机房";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 建筑布局
        private indicatorDetails analysisArchitecturalComposition()
        {
            backWork.ReportProgress(0, "建筑布局");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "建筑布局";
            indicator.result = "不通过";
            return indicator;
        }

        // 夜景照明
        private indicatorDetails analysisNightscapeLighting()
        {
            backWork.ReportProgress(0, "夜景照明");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "夜景照明";
            indicator.result = "不通过";
            return indicator;
        }

        // 建筑标识
        private indicatorDetails analysisBuildingSign()
        {
            backWork.ReportProgress(0, "建筑标识");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "建筑标识";
            indicator.result = "不通过";
            return indicator;
        }

        // 立面形式
        private indicatorDetails analysisElevationForm()
        {
            backWork.ReportProgress(0, "立面形式");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "立面形式";
            indicator.result = "不通过";
            return indicator;
        }

        // 出入口构筑物
        private indicatorDetails analysisPassageway()
        {
            backWork.ReportProgress(0, "出入口构筑物");

            indicatorDetails indicator = new indicatorDetails();

            StringBuilder sb = new StringBuilder();
            int i = 1;
            List<ElementId> elements = new List<ElementId>();

            var collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
            foreach (Element elem in collector.ToElements())
            {
                if (elem.Name != null && elem.Name.Contains("出入口"))
                {
                    elements.Add(elem.Id);
                    var location = elem.Location;
                    if (location is LocationCurve locationCurve)
                    {
                        var origin = ((Line)locationCurve.Curve).Origin;
                        sb.Append("[" + i++ + "] ");
                        sb.Append(origin.ToString());
                    }
                    else if (location is LocationPoint locationPoint)
                    {
                        var point = locationPoint.Point;
                        sb.Append("[" + i++ + "] ");
                        sb.Append(point.ToString());
                    }

                    if (collector.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }

            indicator.name = "出入口构筑物";
            indicator.designValue = sb.ToString();
            if (elements.Count != 0)
            {
                indicator.canDoubleClick = true;
                indicator.elementIds = elements;
            }
            indicator.result = "不通过";
            return indicator;
        }

        // 日照
        private indicatorDetails analysisSunlight()
        {
            backWork.ReportProgress(0, "日照");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "日照";
            indicator.result = "不通过";

            return indicator;
        }

        // 市政接驳点位置
        private indicatorDetails analysisMunicipalConnectionPoint()
        {
            backWork.ReportProgress(0, "市政接驳点位置");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            List<ElementId> elements = new List<ElementId>();
            coll.OfCategory(BuiltInCategory.OST_PipeCurves).OfClass(typeof(Pipe));
            foreach (Pipe pipe in coll.ToElements())
            {
                Parameter zhushi = pipe.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS);
                if (zhushi == null || zhushi.AsString() == null || !zhushi.AsString().Contains("接驳管线")) continue;
                elements.Add(pipe.Id);
                var location = pipe.Location;
                var origin = ((Line)((LocationCurve)location).Curve).Origin;
                sb.Append("[" + i++ + "] ");
                sb.Append(origin.ToString());
                if (coll.ToElements().Count + 1 != i)
                    sb.Append("\n");

            }
            indicator.name = "市政接驳点位置";

            indicator.tolerance = "-1m";
            indicator.result = "不通过";

            indicator.designValue = sb.ToString();
            if (elements.Count != 0)
            {
                indicator.canDoubleClick = true;
                indicator.elementIds = elements;
            }
            return indicator;
        }

        // 项目编号
        private indicatorDetails analysisProjectCode()
        {
            backWork.ReportProgress(0, "项目编号");

            indicatorDetails indicator = new indicatorDetails();
            Document doc = UIApp.ActiveUIDocument.Document;
            ProjectInfo proj = doc.ProjectInformation;
            if (proj.LookupParameter("项目编号") != null)
                indicator.designValue = proj.LookupParameter("项目编号").AsString();
            if (indicator.designValue != null)
            {
                indicator.result = "通过";
                indicator.tolerance = "无";
                indicator.planningControlValue = indicator.designValue;
            }
            else
            {
                indicator.result = "不通过";
            }

            indicator.name = "项目编号";
            
            return indicator;
        }

        // 项目名称
        private indicatorDetails analysisProjectName()
        {
            backWork.ReportProgress(0, "项目名称");

            indicatorDetails indicator = new indicatorDetails();

            Document doc = UIApp.ActiveUIDocument.Document;
            ProjectInfo proj = doc.ProjectInformation;
            if (proj.LookupParameter("项目名称") != null)
                indicator.designValue = proj.LookupParameter("项目名称").AsString();
            
            if (indicator.designValue != null)
            {
                indicator.result = "通过";
                indicator.tolerance = "无";
                indicator.planningControlValue = indicator.designValue;
            }
            else
            {
                indicator.result = "不通过";
            }

            indicator.name = "项目名称";
            // indicator.result = "不通过";

            return indicator;
        }

        // 地块编号
        private indicatorDetails analysisPlotCode()
        {
            backWork.ReportProgress(0, "地块编号");

            indicatorDetails indicator = new indicatorDetails();

            Document doc = UIApp.ActiveUIDocument.Document;
            ProjectInfo proj = doc.ProjectInformation;
            if (proj.LookupParameter("地块编号") != null)
                indicator.designValue = proj.LookupParameter("地块编号").AsString();
            if (indicator.designValue != null)
            {
                indicator.result = "通过";
                indicator.tolerance = "无";
                indicator.planningControlValue = indicator.designValue;
            }
            else
            {
                indicator.result = "不通过";
            }

            indicator.name = "地块编号";
            // indicator.result = "不通过";

            return indicator;
        }

        // 用地性质
        private indicatorDetails analysisLandUsage()
        {
            backWork.ReportProgress(0, "用地性质");

            indicatorDetails indicator = new indicatorDetails();

            Document doc = UIApp.ActiveUIDocument.Document;
            ProjectInfo proj = doc.ProjectInformation;
            if (proj.LookupParameter("用地性质") != null)
                indicator.designValue = proj.LookupParameter("用地性质").AsString();
            if (indicator.designValue != null)
            {
                indicator.result = "通过";
                indicator.tolerance = "无";
                indicator.planningControlValue = indicator.designValue;
            }
            else
            {
                indicator.result = "不通过";
            }

            indicator.name = "用地性质";
            // indicator.result = "不通过";

            return indicator;
        }

        // 用地面积
        private indicatorDetails analysisSiteArea()
        {
            backWork.ReportProgress(0, "用地面积");

            indicatorDetails indicator = new indicatorDetails();

            Document doc = UIApp.ActiveUIDocument.Document;
            ProjectInfo proj = doc.ProjectInformation;
            if (proj.LookupParameter("用地面积") != null)
                indicator.designValue = proj.LookupParameter("用地面积").AsString();
            if (indicator.designValue != null)
            {
                indicator.result = "通过";
                indicator.tolerance = "无";
                indicator.planningControlValue = indicator.designValue;
            }
            else
            {
                indicator.result = "不通过";
            }

            indicator.name = "用地面积";
            // indicator.result = "不通过";

            return indicator;
        }

        // 应急避难场所面积
        private indicatorDetails analysisEmergencyShelterArea()
        {
            backWork.ReportProgress(0, "应急避难场所面积");

            indicatorDetails indicator = new indicatorDetails();

            var collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
            double emergencyShelterArea = 0;
            foreach (Element elem in collector.ToElements())
            {
                if (elem.Name != null && elem.Name.Contains("场地"))
                {
                    var flag = elem.LookupParameter("是否为应急避险场地");
                    if (flag != null && flag.AsInteger() == 1)
                    {
                        var area = elem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);// 面积
                        if (area != null)
                            emergencyShelterArea += UnitUtils.ConvertFromInternalUnits(area.AsDouble(), area.DisplayUnitType);
                    }

                }
            }

            indicator.name = "应急避难场所面积";
            indicator.designValue = emergencyShelterArea.ToString("0.000");
            indicator.result = "不通过";
            return indicator;
        }

        // 抗震等级
        private indicatorDetails analysisSeismicGrade()
        {
            backWork.ReportProgress(0, "抗震等级");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("抗震等级");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "抗震等级";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }
        // 结构形式
        private indicatorDetails analysisStructural()
        {
            backWork.ReportProgress(0, "结构形式");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("结构形式");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "结构形式";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 不可回收(构)件数量
        private indicatorDetails analysisNonRecyclable()
        {
            backWork.ReportProgress(0, "不可回收(构)件数量");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            List<ElementId> elementIds = new List<ElementId>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.WhereElementIsNotElementType();
                int i = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Parameter Non_recyclable = elem.LookupParameter("不可回收构件");
                    if (Non_recyclable != null && Non_recyclable.AsInteger() == 1)
                    {
                        elementIds.Add(elem.Id);
                        i++;
                    }
                }
                strings.Add("[" + j++ + "] " + i);
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "不可回收(构)件数量";
            indicator.designValue = designValue;
            indicator.canDoubleClick = true;
            indicator.elementIds = elementIds;
            indicator.canDoubleClick = true;
            indicator.result = "不通过";
            return indicator;
        }

        // 居住户数
        private indicatorDetails analysisHouseholds()
        {
            backWork.ReportProgress(0, "居住户数");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("居住户数");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsInteger();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "居住户数";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 居住人数
        private indicatorDetails analysisNumberOfHouseholds()
        {
            backWork.ReportProgress(0, "居住人数");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("居住人数");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsInteger();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "居住人数";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 人防所在层数
        private indicatorDetails analysisFloorOfPeopleAirDefence()
        {
            backWork.ReportProgress(0, "人防所在层数");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("功能分区类别");
                    if (type != null && type.AsString() != null && type.AsString().Contains("人防分区"))
                    {
                        var LEVEL_NAME = elem.get_Parameter(BuiltInParameter.LEVEL_NAME);
                        if (LEVEL_NAME != null)
                        {
                            value = "[" + j + "] ";
                            value += LEVEL_NAME.AsString() + " ";
                        }
                    }
                }
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "人防所在层数";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }
        // 防护单元建筑面积
        private indicatorDetails analysisBuildingAreaOfProtectiveUnit()
        {
            backWork.ReportProgress(0, "防护单元建筑面积");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                double roomArea = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("功能分区类别");
                    if (type != null && type.AsString() != null && type.AsString().Contains("人防"))
                    {
                        var p1 = elem.LookupParameter("人防工程组成");
                        if (p1 != null && "防护单元".Equals(p1.AsString()))
                        {
                            var room_area = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                            if (room_area != null)
                                roomArea += UnitUtils.ConvertFromInternalUnits(room_area.AsDouble(), room_area.DisplayUnitType); // 面积
                        }
                    }
                }
                strings.Add("[" + j + "] " + roomArea.ToString("0.000"));
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "防护单元建筑面积";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }
        // 战时出入口建筑面积
        private indicatorDetails analysisBuildingAreaOfWartimeEntrancesAndExits()
        {
            backWork.ReportProgress(0, "战时出入口建筑面积");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                double roomArea = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("功能分区类别");
                    if (type != null && type.AsString() != null && type.AsString().Contains("人防"))
                    {
                        var p1 = elem.LookupParameter("人防工程组成");
                        if (p1 != null && "战时出入口区域".Equals(p1.AsString()))
                        {
                            var room_area = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                            if (room_area != null)
                                roomArea += UnitUtils.ConvertFromInternalUnits(room_area.AsDouble(), room_area.DisplayUnitType); // 面积
                        }
                    }
                }
                strings.Add("[" + j + "] " + roomArea.ToString("0.000"));
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "战时出入口建筑面积";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }
        // 防倒塌棚架建筑面积
        private indicatorDetails analysisBuildingAreaOfAntiCollapseScaffolding()
        {
            backWork.ReportProgress(0, "防倒塌棚架建筑面积");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                double roomArea = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("功能分区类别");
                    if (type != null && type.AsString() != null && type.AsString().Contains("人防"))
                    {
                        var p1 = elem.LookupParameter("人防工程组成");
                        if (p1 != null && "防倒塌棚架区域".Equals(p1.AsString()))
                        {
                            var room_area = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                            if (room_area != null)
                                roomArea += UnitUtils.ConvertFromInternalUnits(room_area.AsDouble(), room_area.DisplayUnitType); // 面积
                        }
                    }
                }
                strings.Add("[" + j + "] " + roomArea.ToString("0.000"));
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "防倒塌棚架建筑面积";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }
        // 其他可计入人防的建筑面积
        private indicatorDetails analysisOtherBuildingAreasOfCivilAirDefense()
        {
            backWork.ReportProgress(0, "其他可计入人防的建筑面积");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Areas);
                string value = string.Empty;
                double roomArea = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Area area = elem as Area;
                    if (area == null) continue;

                    Parameter type = elem.LookupParameter("功能分区类别");
                    if (type != null && type.AsString() != null && type.AsString().Contains("人防"))
                    {
                        var p1 = elem.LookupParameter("人防工程组成");
                        if (p1 != null && "其他人防区域".Equals(p1.AsString()))
                        {
                            var room_area = elem.get_Parameter(BuiltInParameter.ROOM_AREA);
                            if (room_area != null)
                                roomArea += UnitUtils.ConvertFromInternalUnits(room_area.AsDouble(), room_area.DisplayUnitType); // 面积
                        }
                    }
                }
                strings.Add("[" + j + "] " + roomArea.ToString("0.000"));
                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add(value);
                j++;
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "其他可计入人防的建筑面积";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 消防车道
        private indicatorDetails analysisFireLane()
        {
            backWork.ReportProgress(0, "消防车道");

            indicatorDetails indicator = new indicatorDetails();

            StringBuilder sb = new StringBuilder();
            int i = 1;
            List<ElementId> elements = new List<ElementId>();

            var collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
            foreach (Element elem in collector.ToElements())
            {
                if (elem.Name != null && elem.Name.Contains("道路"))
                {
                    var flag = elem.LookupParameter("是否为消防登高场地");
                    if (flag != null && flag.AsInteger() == 1)
                    {
                        elements.Add(elem.Id);
                        var location = elem.Location;
                        var origin = ((Line)((LocationCurve)location).Curve).Origin;
                        sb.Append("[" + i++ + "] ");
                        sb.Append(origin.ToString());
                        if (collector.ToElements().Count + 1 != i)
                            sb.Append("\n");
                    }

                }
            }

            indicator.name = "消防车道";
            indicator.designValue = sb.ToString();
            if (elements.Count != 0)
            {
                indicator.canDoubleClick = true;
                indicator.elementIds = elements;
            }
            indicator.result = "不通过";
            return indicator;
        }

        // 消防登高场地面积
        private indicatorDetails analysisAreaOfFirefightingClimbingSite()
        {
            backWork.ReportProgress(0, "消防登高场地面积");

            indicatorDetails indicator = new indicatorDetails();

            var collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
            double emergencyShelterArea = 0;
            foreach (Element elem in collector.ToElements())
            {
                var paramName = elem.LookupParameter("名称");
                if (paramName != null && paramName.AsString() != null && paramName.AsString().Contains("场地"))
                {
                    if (elem.LookupParameter("名称").AsString() != null && elem.LookupParameter("名称").AsString().Contains("场地"))
                    {
                        var flag = elem.LookupParameter("是否为消防登高场地");
                        if (flag != null && flag.AsInteger() == 1)
                        {
                            var area = elem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);// 面积
                            if (area != null)
                                emergencyShelterArea += UnitUtils.ConvertFromInternalUnits(area.AsDouble(), area.DisplayUnitType);
                        }

                    }
                }
                
                else
                {
                    indicator.designValue = " ";
                }
            }

            indicator.name = "消防登高场地面积";
            indicator.designValue = emergencyShelterArea.ToString("0.000");
            indicator.result = "不通过";
            return indicator;
        }

        // 消火栓位置
        private indicatorDetails analysisFireHydrantLocation()
        {
            backWork.ReportProgress(0, "消火栓位置");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            List<ElementId> elementIds = new List<ElementId>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.WhereElementIsNotElementType();
                int i = 0;
                foreach (Element elem in collector.ToElements())
                {
                    Parameter Non_recyclable = elem.LookupParameter("消火栓");
                    if (Non_recyclable != null && Non_recyclable.AsString() != null )
                    {
                        elementIds.Add(elem.Id);
                        i++;
                    }
                }
                strings.Add("[" + j++ + "] " + i);
            }
            string designValue = string.Empty;
            for (int i = 0; i < strings.Count; i++)
            {
                designValue += strings[i];
                if (i + 1 != strings.Count)
                {
                    designValue = designValue + "\n";
                }
            }

            indicator.name = "消火栓位置";
            indicator.designValue = designValue;
            indicator.canDoubleClick = true;
            indicator.elementIds = elementIds;
            indicator.result = "不通过";
            return indicator;
        }

        // 能耗
        private indicatorDetails analysisEnergyConsumption()
        {
            backWork.ReportProgress(0, "能耗");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("单位面积能耗");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "能耗";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 声环境功能区防噪音设备位置
        private indicatorDetails analysisNoiseEquipment()
        {
            backWork.ReportProgress(0, "声环境功能区防噪音设备位置");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "声环境功能区防噪音设备位置";
            indicator.result = "不通过";

            return indicator;
        }

        // 透水铺装面积比例
        private indicatorDetails analysisPermeablePavement()
        {
            backWork.ReportProgress(0, "透水铺装面积比例");

            indicatorDetails indicator = new indicatorDetails();

            var collector = new FilteredElementCollector(doc);
            collector.OfCategory(BuiltInCategory.OST_Site).OfClass(typeof(FamilyInstance));
            double emergencyShelterArea = 0;
            double totalArea = 0;


            foreach (Element elem in collector.ToElements())
            {
                var paramName = elem.LookupParameter("名称");
                if (paramName != null && paramName.AsString() != null && paramName.AsString().Contains("场地"))
                {
                    if (elem.LookupParameter("名称").AsString() != null && elem.LookupParameter("名称").AsString().Contains("场地"))
                    {
                        var flag = elem.LookupParameter("铺装");
                        if (flag != null && flag.AsString() == "透水")
                        {
                            var area = elem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);// 面积
                            if (area != null)
                                emergencyShelterArea += UnitUtils.ConvertFromInternalUnits(area.AsDouble(), area.DisplayUnitType);
                        }

                    }

                    if (elem.LookupParameter("名称").AsString() != null && elem.LookupParameter("名称").AsString().Contains("场地"))
                    {
                        var Zong = elem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED);// 面积
                        if (Zong != null)
                            totalArea += UnitUtils.ConvertFromInternalUnits(Zong.AsDouble(), Zong.DisplayUnitType);

                    }
                }
                else
                {
                    indicator.designValue = " ";
                }
                
            }

            double permeablePavementRatio = 0;
            if (totalArea > 0)
                permeablePavementRatio = emergencyShelterArea / totalArea * 100;

            indicator.name = "透水铺装面积比例";
            indicator.designValue = permeablePavementRatio.ToString("0.000");
            indicator.result = "不通过";
            return indicator;
        }

        // 雨水调蓄设施

        private indicatorDetails analysisStormwaterFacilities()
        {
            backWork.ReportProgress(0, "雨水调蓄设施");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "雨水调蓄设施";
            indicator.result = "不通过";

            return indicator;
        }

        // 外排径流系数
        private indicatorDetails analysisExternalDrainageRunoffCoefficient()
        {
            backWork.ReportProgress(0, "外排径流系数");

            indicatorDetails indicator = new indicatorDetails();
            string AssemblyRate = "0";
            var projectInformation = doc.ProjectInformation;
            var parameter = projectInformation.LookupParameter("外排径流系数");
            if (parameter != null)
            {
                AssemblyRate = parameter.AsString();
            }

            indicator.name = "外排径流系数";
            indicator.designValue = AssemblyRate;
            indicator.result = "不通过";
            return indicator;
        }

        // 装配构件

        private indicatorDetails analysisAssemblyMember()
        {
            backWork.ReportProgress(0, "装配构件");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "装配构件";
            indicator.result = "不通过";

            return indicator;
        }

        // 单体装配率
        private indicatorDetails analysisAssemblyRate()
        {
            backWork.ReportProgress(0, "单体装配率");
            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;

            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                string AssemblyRate = "0";
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("装配率");
                if (parameter != null)
                {
                    AssemblyRate = parameter.AsString();
                }
                sb.Append("[" + i++ + "] ");
                sb.Append(AssemblyRate);
                if (coll.ToElements().Count + 1 != i)
                    sb.Append("\n");
            }
            indicator.name = "单体装配率";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 整体装配率
        private indicatorDetails analysisOverallAssemblyRate()
        {
            backWork.ReportProgress(0, "整体装配率");

            indicatorDetails indicator = new indicatorDetails();
            string AssemblyRate = "0";
            var projectInformation = doc.ProjectInformation;
            var parameter = projectInformation.LookupParameter("装配率");
            if (parameter != null)
            {
                AssemblyRate = parameter.AsString();
            }

            indicator.name = "整体装配率";
            indicator.designValue = AssemblyRate;
            indicator.result = "不通过";
            return indicator;
        }

        // 设备能效指标

        private indicatorDetails analysisEquipmentIndex()
        {
            backWork.ReportProgress(0, "设备能效指标");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "设备能效指标";
            indicator.result = "不通过";

            return indicator;
        }

        // 消防水源

        private indicatorDetails analysisFireWaterSource()
        {
            backWork.ReportProgress(0, "消防水源");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "消防水源";
            indicator.result = "不通过";

            return indicator;
        }

        // 消防水源管径

        private indicatorDetails analysisWaterPipeDiameter()
        {
            backWork.ReportProgress(0, "消防水源管径");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "消防水源管径";
            indicator.result = "不通过";

            return indicator;
        }

        // 消防水源容积

        private indicatorDetails analysisVolumeOfWaterSource()
        {
            backWork.ReportProgress(0, "消防水源容积");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "消防水源容积";
            indicator.result = "不通过";

            return indicator;
        }

        // 消防水源供水压力

        private indicatorDetails analysisPressureOfSupplyWater()
        {
            backWork.ReportProgress(0, "消防水源供水压力");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "消防水源供水压力";
            indicator.result = "不通过";

            return indicator;
        }

        // 消防设计用水量
        private indicatorDetails analysisFireProtectionDesignWaterConsumption()
        {
            backWork.ReportProgress(0, "消防设计用水量");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("消防设计用水量");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "消防设计用水量";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 给水用水量
        private indicatorDetails analysisWaterConsumptionForWaterSupply()
        {
            backWork.ReportProgress(0, "给水用水量");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("给水用水量");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "给水用水量";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 再生水用水量
        private indicatorDetails analysisRegeneratedWaterConsumption()
        {
            backWork.ReportProgress(0, "再生水用水量");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("再生水用水量");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "再生水用水量";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 给水水压

        private indicatorDetails analysisFeedWaterPressure()
        {
            backWork.ReportProgress(0, "给水水压");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "给水水压";
            indicator.result = "不通过";

            return indicator;
        }

        // 给水水源

        private indicatorDetails analysisWaterSource()
        {
            backWork.ReportProgress(0, "给水水源");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "给水水源";
            indicator.result = "不通过";

            return indicator;
        }

        // 给水水源接入管径

        private indicatorDetails analysisWaterSourcePipeDiameter()
        {
            backWork.ReportProgress(0, "给水水源接入管径");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "给水水源接入管径";
            indicator.result = "不通过";

            return indicator;
        }

        // 废水量
        private indicatorDetails analysisWasteWaterVolume()
        {
            backWork.ReportProgress(0, "废水量");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("废水量");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "废水量";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }
        // 污水量
        private indicatorDetails analysisSewageVolume()
        {
            backWork.ReportProgress(0, "污水量");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("污水量");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "污水量";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }
        // 分区设计小时耗热量
        private indicatorDetails analysisHourlyHeatConsumptionInZoningDesign()
        {
            backWork.ReportProgress(0, "分区设计小时耗热量");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("分区设计小时耗热量");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "分区设计小时耗热量";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }
        // 最高日热水用量
        private indicatorDetails analysisMaximumDailyHotWaterConsumption()
        {
            backWork.ReportProgress(0, "最高日热水用量");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("热水用量（最高日）");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "最高日热水用量";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        // 热水系统热源
        private indicatorDetails analysisHotWaterSystem()
        {
            backWork.ReportProgress(0, "热水系统热源");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "热水系统热源";
            indicator.result = "不通过";

            return indicator;
        }

        // 热水系统供应方式
        private indicatorDetails analysisHotWaterSupplyMode()
        {
            backWork.ReportProgress(0, "热水系统供应方式");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "热水系统供应方式";
            indicator.result = "不通过";

            return indicator;
        }

        // 热水系统供应部位
        private indicatorDetails analysisHotWaterSupplySite()
        {
            backWork.ReportProgress(0, "热水系统供应部位");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "热水系统供应部位";
            indicator.result = "不通过";

            return indicator;
        }

        // 供电电源
        private indicatorDetails analysisPowerSupply()
        {
            backWork.ReportProgress(0, "供电电源");

            indicatorDetails indicator = new indicatorDetails();


            indicator.name = "供电电源";
            indicator.result = "不通过";

            return indicator;
        }

        public class spaceInfo
        {
            public string id { get; set; }
            public string space_code { get; set; }
            public string room_function { get; set; }
            public string equipment_model { get; set; }
            public string equipment_capacity { get; set; }
            public decimal capacity_area { get; set; } // 计容面积
            public decimal area { get; set; } // 计容面积
        }

        public class Pli
        {
            public string Id { get; set; }
            public string code { get; set; }
            public string name { get; set; }

            public string type { get; set; }
            public string professional_type { get; set; }
            public string system_type { get; set; }
            public string cable_specifications { get; set; }
        }

        // 进户高压电缆规格
        private indicatorDetails analysisHighVoltageCable()
        {
            backWork.ReportProgress(0, "进户高压电缆规格");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                // MessageBox.Show($"{coll.ToElements().Count()}");
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_PipeCurves).OfClass(typeof(Pipe));
                string value = string.Empty;
                foreach (Element elem in collector.ToElements())
                {
                    pipeline pl = new pipeline();
                    if (elem.LookupParameter("进户高压电缆规格") != null)
                        pl.cable_specifications = elem.LookupParameter("进户高压电缆规格").AsString();
                        value += pl.cable_specifications;
                }
                // MessageBox.Show($"进户高压 {value}");

                if (!string.IsNullOrEmpty(value) && !strings.Contains(value))
                    strings.Add("[" + j + "] :" + value);
                j++;
            }

            string designValue = string.Join("\n", strings);

            indicator.name = "进户高压电缆规格";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 应急电源功率
        private indicatorDetails analysisEmergencyPower()
        {
            backWork.ReportProgress(0, "应急电源功率");

            indicatorDetails indicator = new indicatorDetails();

            indicator.name = "应急电源功率";
            indicator.result = "不通过";

            return indicator;
        }

        // 应急电源容量
        private indicatorDetails analysisEmergencyPowerCapacity()
        {
            backWork.ReportProgress(0, "应急电源容量");

            indicatorDetails indicator = new indicatorDetails();

            indicator.name = "应急电源容量";
            indicator.result = "不通过";

            return indicator;
        }

        // 变配电室设备安装型号
        private indicatorDetails analysisDistributionRoomModel()
        {
            backWork.ReportProgress(0, "变配电室设备安装型号");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Rooms);
                string value = string.Empty;
                List<spaceInfo> spaceInfos = new List<spaceInfo>();

                foreach (Element elem in collector.ToElements())
                {
                    Room room = elem as Room;
                    if (room == null) continue;
                    spaceInfo space = new spaceInfo();

                    space.id = elem.Id.ToString(); // ID
                    if (room.LookupParameter("房间功能") != null && room.LookupParameter("房间功能").AsString() != null && room.LookupParameter("房间功能").AsString().Contains("变配电房"))
                    {
                        space.room_function = elem.LookupParameter("房间功能").AsString();

                        if (room.LookupParameter("安装型号") != null && room.LookupParameter("安装型号").AsString() != null)
                        {
                            space.equipment_capacity = room.LookupParameter("安装型号").AsString().ToString();
                        }
                    }
                    spaceInfos.Add(space);
                }

                foreach (spaceInfo space in spaceInfos)
                {
                    if (!string.IsNullOrEmpty(space.equipment_capacity))
                    {
                        strings.Add("[" + j + "] " + space.equipment_capacity + " in room " + space.id);
                        j++;
                    }
                }
            }

            string designValue = string.Join("\n", strings);

            indicator.name = "变配电室设备安装型号";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 变配电室设备安装容量
        private indicatorDetails analysisDistributionRoomCapacity()
        {
            backWork.ReportProgress(0, "变配电室设备安装容量");

            indicatorDetails indicator = new indicatorDetails();
            List<string> strings = new List<string>();
            int j = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document LinkDoc = LinkInstance.GetLinkDocument();
                if (LinkDoc == null) continue;
                var collector = new FilteredElementCollector(LinkDoc);
                collector.OfCategory(BuiltInCategory.OST_Rooms);
                string value = string.Empty;
                List<spaceInfo> spaceInfos = new List<spaceInfo>();

                foreach (Element elem in collector.ToElements())
                {
                    Room room = elem as Room;
                    if (room == null) continue;
                    spaceInfo space = new spaceInfo();

                    space.id = elem.Id.ToString(); // ID
                    if (room.LookupParameter("房间功能") != null && room.LookupParameter("房间功能").AsString() != null && room.LookupParameter("房间功能").AsString().Contains("变配电房"))
                    {
                        space.room_function = elem.LookupParameter("房间功能").AsString();

                        if (room.LookupParameter("安装容量") != null && room.LookupParameter("安装容量").AsDouble() != null)
                        {
                            space.equipment_capacity = room.LookupParameter("安装容量").AsDouble().ToString();
                        }
                    }
                    spaceInfos.Add(space);
                }

                foreach (spaceInfo space in spaceInfos)
                {
                    if (!string.IsNullOrEmpty(space.equipment_capacity))
                    {
                        strings.Add("[" + j + "] " + space.equipment_capacity + " in room " + space.id);
                        j++;
                    }
                }
            }

            string designValue = string.Join("\n", strings);

            indicator.name = "变配电室设备安装容量";
            indicator.designValue = designValue;
            indicator.result = "不通过";
            return indicator;
        }

        // 建筑物防雷

        private indicatorDetails analysisBuildingLightningProtector()
        {
            backWork.ReportProgress(0, "建筑物防雷");

            indicatorDetails indicator = new indicatorDetails();

            indicator.name = "建筑物防雷";
            indicator.result = "不通过";

            return indicator;
        }

        // 可再生能源比例
        private indicatorDetails analysisRenewableEnergyRatio()
        {
            backWork.ReportProgress(0, "可再生能源比例");

            indicatorDetails indicator = new indicatorDetails();
            StringBuilder sb = new StringBuilder();
            int i = 1;
            var coll = new FilteredElementCollector(doc);
            coll.OfClass(typeof(RevitLinkInstance));
            foreach (RevitLinkInstance LinkInstance in coll.ToElements())
            {
                Document linkDoc = LinkInstance.GetLinkDocument();
                if (linkDoc == null) continue;
                var projectInformation = linkDoc.ProjectInformation;
                var parameter = projectInformation.LookupParameter("可再生能源比例");
                if (parameter != null)
                {
                    var seismicGrade = parameter.AsValueString();
                    sb.Append("[" + i++ + "] ");
                    sb.Append(seismicGrade);
                    if (coll.ToElements().Count + 1 != i)
                        sb.Append("\n");
                }
            }
            indicator.name = "可再生能源比例";
            indicator.designValue = sb.ToString();
            indicator.result = "不通过";
            return indicator;
        }

        

        #endregion

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}